package edu.wtbu.cs.androiddemo.activity.store;

import android.content.Context;
import android.content.SharedPreferences;


import java.util.HashMap;
import java.util.Map;

public class SPSaveInfo implements SaveInfo{

    public  boolean saveInfoToFile(Context context, String userName, String userPwd) {
        SharedPreferences preferences = context.getSharedPreferences("data",Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("userName",userName);
        editor.putString("userPwd",userPwd);
        editor.commit();
        return true;
    }

    public  Map<String, String> getInfoFromFile(Context context) {
        HashMap<String, String> userMap = new HashMap<>();
        SharedPreferences preferences = context.getSharedPreferences("data",Context.MODE_PRIVATE);
        String userName = preferences.getString("userName","");
        String userPwd = preferences.getString("userPwd","");

        userMap.put("userName", userName);
        userMap.put("userPwd", userPwd);
        return userMap;
    }
}
